Skip to main content

Transaction Initialization

This endpoint verifies that a customer exists in the Presto system and returns the necessary information to present a confirmation prompt to your users.

Overview

The wallet initialization endpoint is the first step in the wallet top-up process. It performs several critical functions:

  • Validates that the provided identifier (phone, email, or user ID) belongs to a registered Presto user
  • Verifies the customer's wallet status in the Presto registry
  • Returns non-sensitive customer information for display in your confirmation interface
  • Generates a unique transaction reference for tracking the top-up request

Endpoint Flow

The following diagram illustrates the wallet initialization process:

Endpoint Details

Method: POST
URL: /api/institutions/v1/wallet/init
Purpose: Initiate a wallet top-up request and validate customer information

Authentication Required

All API calls require a valid authentication token. Invalid or expired tokens will result in a 401 Unauthorized response.

Request Specification

Request Parameters

ParameterTypeRequiredDescription
customerobjectYesContainer for customer identification information
customer.identifier_typestringYesType of identifier being provided. Valid values: "phone", "email", "uid"
customer.identifierstringYesThe actual identifier value:
• For "phone": E.164 format (country code + number, no leading "+")
• For "email": Valid email address
• For "uid": Presto user ID
amountnumberYesAmount to credit to the customer's wallet. Must be positive and support up to 3 decimal places
currencystringYesCurrency code for the amount. Currently supported: "LYD"
Identifier Format

When using phone numbers, ensure they are in E.164 format without the leading plus sign. For example, use "218920000000" instead of "+218920000000".

Example Request

// Headers:
// Authorization: Bearer {token}
// Content-Type: application/json

{
"customer": {
"identifier_type": "phone",
"identifier": "218920000000"
},
"amount": 200.00,
"currency": "LYD"
}

Response Specification

Success Response

200 OK

A successful response contains the transaction status, a unique transaction reference, and basic customer information for display.

{
"data": {
"status": "pending",
"transaction_reference": "123FNS2Wsdsd3D",
"customer": {
"name": "MOH… OK…",
"phone": "218920000000"
},
"ttl": "2025-05-25T18:49:51+00:00"
}
}

Response Fields

FieldTypeDescription
statusstringCurrent status of the transaction. Possible value: "pending"
transaction_referencestringUnique identifier for the transaction to be used in subsequent API calls
customerobjectCustomer information for display to the user
customer.namestringPartially masked customer name for verification
customer.phonestringCustomer phone number
ttlstringISO 8601 timestamp when the transaction will expire (15 minutes from now)
Transaction Expiration

The ttl field indicates when the transaction will expire. If not confirmed within this period (15 minutes), the transaction will expire and you'll need to initialize a new one.

Error Responses

401 Unauthorized - Authentication issues

{
"message": "Invalid or expired authentication token"
}

404 Not Found - Customer validation issues

{
"message": "Customer not found"
}

422 Unprocessable Content - Input validation issues

{
"message": "The customer.identifier_type field is required.",
"errors": {
"customer.identifier_type": [
"The customer.identifier_type field is required."
]
}
}

Error Handling

Common Errors
HTTP StatusError TypeExample MessageWhen it Occurs / Resolution
401Unauthorized{"message": "Invalid or expired authentication token"}Missing or invalid authentication token. Provide a valid token.
404Customer not found{"message": "Customer not found"}The customer identifier does not match any user. Check the identifier.
422Validation error{"message": "The customer.identifier_type field is required.", "errors": { ... }}Required fields are missing or invalid. Check the errors object for details.
500Internal server error{"message": "Failed to process request: ..."}Unexpected server error. Try again or contact support.

Implementation Tips

Best Practices
  • Always validate user input before making the API call
  • Store the transaction reference securely for the confirmation step
  • Display clear feedback to users when validation fails
  • Consider implementing a countdown timer for the 15-minute validity period

Next Steps

After successfully initializing a wallet top-up, proceed to confirm the transaction using the Wallet Top-Up Confirmation endpoint with the returned transaction reference.

Transaction Expiration

Initialized transactions have a limited validity period. If not confirmed within this period (15 minutes), the transaction will expire and you'll need to initialize a new one.

For more information about the complete wallet top-up process, see Wallet Topup Flow Overview.